package com.blog4j.server.common.component;

import com.blog4j.api.client.FeignUser;
import com.blog4j.api.vo.UserIllegalRecordVo;
import com.blog4j.common.model.LogVo;
import com.blog4j.server.modules.log.service.LogService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author 98k灬
 * @version v1.0.0
 * @Description : 功能描述
 * @Create on : 2024/8/20 19:58
 **/
@Component
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class AsyncService {
    private final LogService logService;
    private final FeignUser feignUser;

    /**
     * 异步添加日志信息
     *
     * @param logVo 日志信息
     */
    @Async("customExecutor")
    public void addLog(LogVo logVo) {
        logService.addLog(logVo);
    }

    /**
     * 记录用户不合法行为
     *
     * @param illegalRecordVo 不合法行为信息
     */
    @Async("customExecutor")
    public void addUserIllegalRecord(UserIllegalRecordVo illegalRecordVo) {
        feignUser.addUserIllegalRecord(illegalRecordVo);
    }
}
